// 学生信息样例类
case class Student(
                    name: String,                     // 姓名
                    isComputerMajor: Boolean,         // 是否计算机相关专业
                    programmingScore: Int,            // 编程课程成绩
                    weeklyTime: Int,                  // 每周可投入时间（小时）
                    hasNoFailedCourses: Boolean,      // 是否无挂科记录
                    hasArtTalent: Boolean,            // 是否有文艺特长
                    canRehearseTwice: Boolean,        // 能否参加每周2次排练
                    grade: String,                    // 年级（大一/大二/大三/大四）
                    peScore: Int,                     // 体育课程成绩
                    hasNoSeriousDisease: Boolean,     // 是否无重大疾病史
                    meetsFitnessReq: Boolean          // 是否满足对应项目体能要求
                  )

object ActivityAudit {
  def main(args: Array[String]): Unit = {
    // 测试用例
    val testStudents = List(
      // 1. 全通过（孙七）
      Student(
        name = "孙七",
        isComputerMajor = true,
        programmingScore = 90,
        weeklyTime = 15,
        hasNoFailedCourses = true,
        hasArtTalent = true,
        canRehearseTwice = true,
        grade = "大一",
        peScore = 85,
        hasNoSeriousDisease = true,
        meetsFitnessReq = true
      ),
      // 2. 仅通过编程大赛
      Student(
        name = "张三",
        isComputerMajor = false,
        programmingScore = 85,
        weeklyTime = 10,
        hasNoFailedCourses = true,
        hasArtTalent = false,
        canRehearseTwice = false,
        grade = "大三",
        peScore = 75,
        hasNoSeriousDisease = true,
        meetsFitnessReq = false
      ),
      // 3. 仅通过文艺汇演
      Student(
        name = "李四",
        isComputerMajor = false,
        programmingScore = 80,
        weeklyTime = 8,
        hasNoFailedCourses = false,
        hasArtTalent = true,
        canRehearseTwice = true,
        grade = "大二",
        peScore = 70,
        hasNoSeriousDisease = false,
        meetsFitnessReq = false
      ),
      // 4. 仅通过田径运动会
      Student(
        name = "王五",
        isComputerMajor = false,
        programmingScore = 70,
        weeklyTime = 5,
        hasNoFailedCourses = false,
        hasArtTalent = false,
        canRehearseTwice = false,
        grade = "大三",
        peScore = 80,
        hasNoSeriousDisease = true,
        meetsFitnessReq = true
      ),
      // 5. 全不通过
      Student(
        name = "赵六",
        isComputerMajor = false,
        programmingScore = 75,
        weeklyTime = 5,
        hasNoFailedCourses = false,
        hasArtTalent = false,
        canRehearseTwice = false,
        grade = "大三",
        peScore = 75,
        hasNoSeriousDisease = false,
        meetsFitnessReq = false
      )
    )

    // 审核所有测试学生并输出结果
    testStudents.foreach(audit)
  }

  // 审核单个学生的报名资格
  def audit(student: Student): Unit = {
    var eligibleActivities = List.empty[String]  // 可参与活动列表
    val reasons = scala.collection.mutable.Map(   // 未通过原因
      "编程大赛" -> "",
      "文艺汇演" -> "",
      "田径运动会" -> ""
    )

    // 1. 审核编程大赛（使用 if 分支嵌套实现多条件组合）
    if (student.isComputerMajor || student.programmingScore >= 85) {
      if (student.weeklyTime >= 10) {
        if (student.hasNoFailedCourses) {
          eligibleActivities = "编程大赛" :: eligibleActivities
        } else {
          reasons("编程大赛") = "有挂科记录"
        }
      } else {
        reasons("编程大赛") = "每周可投入时间不足10小时"
      }
    } else {
      reasons("编程大赛") = "非计算机相关专业且编程课程成绩<85"
    }

    // 2. 审核文艺汇演
    if (student.hasArtTalent) {
      if (student.canRehearseTwice) {
        if (student.grade == "大一" || student.grade == "大二") {
          eligibleActivities = "文艺汇演" :: eligibleActivities
        } else {
          reasons("文艺汇演") = "非大一或大二学生"
        }
      } else {
        reasons("文艺汇演") = "无法参加每周2次排练"
      }
    } else {
      reasons("文艺汇演") = "无文艺特长（唱歌/跳舞/乐器/表演）"
    }

    // 3. 审核田径运动会
    if (student.peScore >= 80) {
      if (student.hasNoSeriousDisease) {
        if (student.meetsFitnessReq) {
          eligibleActivities = "田径运动会" :: eligibleActivities
        } else {
          reasons("田径运动会") = "未满足对应项目体能要求（如跑步项目1000米成绩>4分钟）"
        }
      } else {
        reasons("田径运动会") = "有重大疾病史"
      }
    } else {
      reasons("田径运动会") = "体育课程成绩<80"
    }

    // 输出审核结果
    println(s"学生 ${student.name} 的审核结果：")
    println(s"可参与活动：${eligibleActivities.reverse}")  // 反转列表恢复添加顺序
    reasons.foreach { case (activity, reason) =>
      if (reason.nonEmpty) println(s"未通过 $activity 原因：$reason")
    }
    println("-" * 50)
  }
}